package com.nbsaas.boot;

import com.alibaba.fastjson2.JSON;
import com.nbsaas.boot.script.HotReloadScriptEngine;
import com.nbsaas.boot.script.UniversalHotReloadScriptEngine;

import java.util.HashMap;
import java.util.Map;

public class ScriptTest {
    public static void main(String[] args) throws Exception {
        //kts groovy
        UniversalHotReloadScriptEngine engine = new UniversalHotReloadScriptEngine("groovy");

        Map<String, Object> context=new HashMap<>();
        context.put("name","张三");
        context.put("age",30);
        context.put("sex",1);
        context.put("birthday","1990-01-01");
        context.put("address","北京");
        Object result =engine.execute("classpath:demo.groovy",context);      // 从类路径加载
        System.out.println("脚本执行结果: " + JSON.toJSONString(result));

    }
}